package com.shuqi.model.sharedprefs;

import android.content.Context;
import android.content.SharedPreferences;

import com.shuqi.application.ShuqiApplication;
import com.shuqi.common.utils.Log4an;
import com.shuqi.common.utils.SharedPreferenceUtil;

/***
 * SharedPreferences 中 config 文件 的数据 
 * @author yanghuawei
 */
public class SpConfig {
    private static SpConfig config;
    private SpConfig(){}
    
    public static SpConfig getInstance(){
        if(config == null){
            config = new SpConfig();
        }
        return config;
    }
    
    
    /**获取上一次检查书籍更新的时间(13位)*/
    public long getLastUpdateBookMarkTime(){
        SharedPreferences sp = ShuqiApplication.getContext().getSharedPreferences(SharedPreferenceUtil.SP_NAME_CONFIG, Context.MODE_PRIVATE);
        return sp.getLong(SharedPreferenceUtil.SP_CONFIG_LONG_LASTUPDATEBOOKMARKTIME, 0);
    }
    /**保存检查书籍更新的时间：当前时间(13位)*/
    public boolean saveUpdateBookMarkTime(){
        Log4an.i("SpConfig", "saveUpdateBookMarkTime() 记录检查书籍更新的时间");
        SharedPreferences sp = ShuqiApplication.getContext().getSharedPreferences(SharedPreferenceUtil.SP_NAME_CONFIG, Context.MODE_PRIVATE);
        return sp.edit().putLong(SharedPreferenceUtil.SP_CONFIG_LONG_LASTUPDATEBOOKMARKTIME, System.currentTimeMillis()).commit();
    }
    
    
}
